package cn.com.bsfit.netty.req;

import cn.com.bsfit.netty.utils.StringHelper;
import cn.com.bsfit.netty.config.properties.BaseNettyServerProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 类名 DefaultJsonReqFormat
 * 描述 默认实现JSON请求格式报文
 *
 * @author hedonglin
 * @version 1.0
 * @date 2019/9/29 15:07
 */
@Component
@ConditionalOnProperty(prefix = "netty.server", name = "enable" ,havingValue = "true")
public class DefaultReqDataFormat implements IReqDataFormat {
    @Autowired
    private BaseNettyServerProperties nettyServerProperties;

    @Override
    public List<String> getTopField() {
        return StringHelper.splitToList(nettyServerProperties.getTopFields());
    }

    @Override
    public List<String> getHeadField() {
        return StringHelper.splitToList(nettyServerProperties.getHeadFields());
    }

    @Override
    public List<String> getBodyField() {
        return StringHelper.splitToList(nettyServerProperties.getBodyFields());
    }
}
